
package com.lcy.servlet;



import com.lcy.service.LoginService;
import com.lcy.service.impl.LoginServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.*;
import java.util.Collection;

public class LoginServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //super.doPost(req, resp);
        String userCode = req.getParameter("userCode");
        String userPassword = req.getParameter("userPassword");
        LoginService loginService = new LoginServiceImpl();
        boolean result = loginService.login(userCode,userPassword);
        if(result){
            resp.sendRedirect("jsp/frame.jsp");
        }else{
            resp.sendRedirect("login.jsp");
        }
    }
}

